package server.bootstrap;

import server.HttpProtocolUtil;

import java.io.OutputStream;
import java.net.Socket;

/**
 * @Author: Hugh
 * @Date: 2020/6/1
 */
public class Minicat10BootStrap extends BaseBootStrap{

    /**
     * 完成Minicat 1.0版本
     * 需求：浏览器请求http://localhost:8080,返回一个固定的字符串到页面"Hello Minicat!"
     * @param socket socket
     * @throws Exception
     */
    @Override
    protected void doHandle(Socket socket) throws Exception{
        OutputStream outputStream = socket.getOutputStream();
        String data = "Hello Minicat!";
        String responseText = HttpProtocolUtil.getHttpHeader200(data.getBytes().length) + data;
        outputStream.write(responseText.getBytes());
    }

    @Override
    protected void init() throws Exception {

    }

    @Override
    protected void loadServlet() throws Exception {

    }
}
